package com.woniuxy.core.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//@ConfigurationProperties(prefix = "alipay.config")
@Data
public class AlipayConfiguration {
    private String serverUrl="https://openapi-sandbox.dl.alipaydev.com/gateway.do";
    private String appid="9021000132670235";
    private String privateKey="MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC+Aj476XeiZSpjOt1pXrmVrZlhKvSPJ63TUYoZkq5l/IZo1R6e6r4DkXuwXLU+lSwGqia9Nf4aVylKN7mNwZD7LSZuognhiS7Y+X7EH59odyu8U5y5gNf/Lsmb52+7fj7jPNVD+sYnoTRkxSaERJZJvf3GDet25ZthiHlAv46asxFTJBfFkZ05BthnlRmclmkEeqFowsyy40A14Z8o4ONBhX+oI3klMmvGYeeZixay0cs0Bmo8fC6biUNW52P5GpKURhF4GHVgcuMCboCCFFF6PjQXY3UvFiT80DMrRlYL4bOEMJHl5neFkMrNm/fncsYJe31Aj6WX6jxbaTJte6m7AgMBAAECggEBAINLvYFc1KRMz7t94516LTd2m/P+4LtDKeRKBemh6AzlMGOkUOJzRxXkI9o8VamHHsMENHyuoIXHEOsOEpQX230VN+de5QEJ8GtSC/yt9VMUdg5OoI+2rorQ49NtW1Ht7LrNQHkXAnJD/JZdfT4MvuT5+jAvUjP4eSQuT8skEwBl5zhabbaVDz6GR2D6lL0FJEAT20EtlY+cLT0w5XtS0T4T7iDz8Stf20QJVjqLJ+fdqiv4v13Rq4h3MGml82iwxtpXmM4TSGn1ZyJI46H9miQSBVe2UOWW1C7lRp7w6v5WAwIZnTV4v5WDF+PiSwWaZxg1J2zWMGGaEJO2wv2KeJECgYEA565/NuZlaOcHznzqq0qceso41fPXNag+rbJhLQk4DiFubqpkiRO7D2vzj7fgEwq/bNbBb1+Wq1Di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8BrHN3JE5MQvnL42aYJr/px86oHFdigDxVSBNGVPv6sSVJFM85dd9WJLv+Eyc6oc0q5J4AZpcAn3e6hi26g09aI/dCqzUtnjlMDnODDwfLajih1+r5k0skSsEstYwIDAQAB";
    @Bean
    public AlipayClient config() throws Exception {
        AlipayConfig alipayConfig = new AlipayConfig();
        //设置网关地址
        alipayConfig.setServerUrl(serverUrl);
        //设置应用ID
        alipayConfig.setAppId(appid);
        //设置应用私钥
        alipayConfig.setPrivateKey(privateKey);
        //设置支付宝公钥
        alipayConfig.setAlipayPublicKey(alipayPublicKey);
        //设置请求格式固定值json
        alipayConfig.setFormat("JSON");
        //设置字符集
        alipayConfig.setCharset("UTF-8");
        //设置签名类型
        alipayConfig.setSignType("RSA2");
        //实例化客户端
        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
        return alipayClient;
    }
}
